#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void Test1()
{

}

int main1()
{
    int n, p; cin >> n >> p;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    sort(v.begin(), v.end());

    int _max = v[0];
    int _min = v[n - 1];
    int max_sum = 0;


    for (int i = 0; i < v.size(); i++)
    {
        int _min = v[i] - p;
        int _max = v[i] + p;

        bool x1 = true, x2 = true;
        for (int j = 0; i < v.size(); i++)
        {
            if (x1 && v[j] == _min) { _min = j; x2 = false; }
            if (x2 && v[j] == _max) { _max = j; x2 = false; }
            if (x1 == false && x2 == false) { break; }
        }

        if ((_max - _min + 1) > max_sum) { max_sum = (_max - _min + 1); }

        while (i + 1 < v.size() && v[i + 1] == v[i])
        {
            i++;
        }
    }

    cout << max_sum << endl;
    return 0;
}

int vis(int x, int y)
{
    int z = 1;
    while (y)
    {
        if (y & 1) { z = z * x % 109; }

        y >>= 1;
        x = x * x % 109;
    }
    return z;
}

int main2() {

    int n, m; cin >> n >> m;
    cout << vis(n - 1, m - 1) * n % 109 << endl;
    return 0;
}


